#!/usr/bin/python
#coding:utf-8 

from flask import Flask
from flask_restful import Api, Resource
from flask_docs import ApiDoc
app = Flask(__name__)
# Using CDN
# app.config["API_DOC_CDN"] = True
# Disable document pages
# app.config["API_DOC_ENABLE"] = False
# Methods allowed to be displayed
# app.config["API_DOC_METHODS_LIST"] = ["GET", "POST", "PUT", "DELETE", "PATCH"]
# Custom url_prefix
app.config["API_DOC_URL_PREFIX"] = "/docs/"
# RESTful Api documents to be excluded
# app.config["API_DOC_RESTFUL_EXCLUDE"] = ["todo"]
restful_api = Api(app)
ApiDoc(app, title="Captcha API", version="1.0.0")
class Captcha(Resource):
    """ 验证码图片管理 """
    
    def post(self):
        """
        验证码图片上传
        @@@
        ### description
        > 上传图片
        ### args
        |  args | nullable | request type | type |  remarks |
        |-------|----------|--------------|------|----------|
        |  pathimage |  false   |    body      | image  | 图片 |
        |  timestamp |  false   |    body      | string  | 上传时间戳 |
        ### request
        ```json
        {
            "pathimage": "bitter", 
            "timestamp": "139472874782323"
        }
        ```
        ### return
        ```json
        {
            "code": 200,
            "status":true, 
            "msg": "上传成功", 
            "data": null
        }
        {
            "code": 200,
            "status":false,
            "msg": "上传失败", 
            "data": null
        }
        ```
        @@@
        """
        return {"code": 200,"status":True, "msg": "上传成功", "data": None}

    def get(self):
        """获取 图片验证码信息
        @@@
        ### description
        > 描述
        ### args
        null
        ### request
        ```
        null
        ```
        ### return
        ```json
        {
            "bg": , 
            "msg": "xxx",
            "data": null
        }
        ```
        @@@
        """

        return {"todo": "get todo"}


class Upload(Resource):
    """ 验证码图片管理 """
    def post(self):
        """
        验证码图片上传
        @@@
        ### description
        > 上传图片
        ### args
        |  args | nullable | request type | type |  remarks |
        |-------|----------|--------------|------|----------|
        |  pathimage |  false   |    body      | image  | 图片 |
        |  timestamp |  false   |    body      | string  | 上传时间戳 |
        ### request
        ```json
        {"pathimage": "bitter", "timestamp": "139472874782323"}
        ```
        ### return
        ```json
        {"code": 200,"status":true, "msg": "上传成功", "data": null}
        {"code": 200,"status":false,"msg": "上传失败", "data": null}
        ```
        @@@
        """
        return {"code": 200,"status":True, "msg": "上传成功", "data": None}

# restful_api.add_resource(Upload, "/upload/file")
# restful_api.add_resource(Captcha, "/captcha")
# app.run(host="127.0.0.1", port=8888,debug=False)
